<!DOCTYPE html>
<html>
<head>
    <title>详情展示</title>
    {% include 'admin/common/header.html' %}
    <link rel="stylesheet" href="{{ url_for('static', filename='/admin/admin/css/other/console1.css') }}"/>
</head>
<body>
{# 用户表格 #}
<div class="user-main user-collasped">
    <div class="layui-card">
        <div class="layui-card-body">
            <table id="user-table" lay-filter="user-table"></table>
        </div>
    </div>
</div>
</body>
{# 用户修改操作 #}
<script type="text/html" id="user-bar">
    <button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i class="pear-icon pear-icon-file"></i>
    </button>
</script>


{# 训练时间 #}
<script type="text/html" id="train-time">
    {{ '  {{layui.util.toDateString(d.train_time,  "yyyy-MM-dd HH:mm:ss")}' |safe }}}
</script>

{% include 'admin/common/footer.html' %}


<script type="text/html" id="police-updateTime">
    {{ '  {{layui.util.toDateString(d.update_at,  "yyyy-MM-dd HH:mm:ss")}' |safe }}}
</script>

<script>
layui.use(['layer', 'echarts', 'element', 'count'], function () {
let table = layui.table
let form = layui.form
let $ = layui.jquery
let dtree = layui.dtree
let popup = layui.popup
let common = layui.common
let MODULE_PATH = '/training/result/detail/'

data = []
        {% for training in data %}
            data.push({
                training_name: "{{ training.training_name }}",
                total_time: {{training.total_time}},
                result: {{ training.result }},
                score: {{ training.score }},
                train_at: '{{ training.train_at }}'.replace('T',' ')
            })
        {% endfor %}
// 表格数据
let cols = [
    [
        {title: '训练名称', field: 'training_name', align: 'center',templet:function(data){
                        if(data.training_name === 'AssaultPolice'){
                          return '<span>袭警</span>';
                        } else if(data.training_name === 'Emergency') {
                          return '<span>急症</span>';
                          }
                          else if(data.training_name === 'PrisonerFight') {
                          return '<span>打斗</span>';
                          }
                          else if(data.training_name === 'PrisonerBreak') {
                          return '<span>越狱</span>';
                          }
                          else if(data.training_name === 'FireDisaster') {
                          return '<span>火灾</span>';
                          }
                          else if(data.training_name === 'Earthquake') {
                          return '<span>地震</span>';
                          }
                          else if(data.training_name === 'Explosion') {
                          return '<span>爆炸</span>';
                          }
                          else if(data.training_name === 'InfectiousDiseases') {
                          return '<span>传染病</span>';
                          }else{
                              return '<span>'+data.training_name+'</span>';
                        }
                        }
        },
        {title: '花费时间', field: 'total_time', align: 'center'},
        {title: '训练时间', field: 'train_at', align: 'center'},
        {title: '训练结果', field: 'result', align: 'center',templet:function(data){
                        if(data.result == 1){
                          return '<span style="color: blue">训练通过</span>';
                        } else {
                          return '<span style="color: red">训练失败</span>';
                          }
                        }
        },
        {title: '成绩', field: 'score', align: 'center'},
    ]
]

// 渲染表格数据
table.render({
    elem: '#user-table',
    page: true,
    cols: cols,
    skin: 'line',
    height: 'full-148',
    toolbar: '#user-toolbar', /*工具栏*/
    text: {none: '暂无成绩信息'},
    data:data,
    defaultToolbar: [{layEvent: 'refresh', icon: 'layui-icon-refresh'}, 'filter', 'print', 'exports'] /*默认工具栏*/
})



$('.user-group').click(function () {
    let group = $(this).attr('user-group')
    let field = form.val('user-query-form')
    if (group === '-1') {
        field.deptId = group
        $(this).removeClass('button-default')
        $(this).prev().removeClass('button-primary')
        $(this).prev().addClass('button-default')
        $(this).addClass('button-primary')
    } else {
        field.deptId = group
        $(this).removeClass('button-default')
        $(this).next().removeClass('button-primary')
        $(this).next().addClass('button-default')
        $(this).addClass('button-primary')
    }
    window.refresh(field)
})

table.on('tool(user-table)', function (obj) {
    if (obj.event === 'remove') {
        window.remove(obj)
    } else if (obj.event === 'edit') {
        window.edit(obj)
    }
})

table.on('toolbar(user-table)', function (obj) {
    if (obj.event === 'refresh') {
        window.refresh()
    } else if (obj.event === 'batchRemove') {
        window.batchRemove(obj)
    } else if (obj.event === 'collasped') {
        $('.user-left').toggleClass('user-collasped')
        $('.user-main').toggleClass('user-collasped')
        table.resize()
    }
})

form.on('submit(user-query)', function (data) {
    window.refresh(data.field)
    return false
})


window.refresh = function (param) {
    table.reload('user-table', {where: param})
}
})
</script>

</html>